package com.gxa.modules.pc.fee.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Result;
import com.gxa.modules.model.entity.fee.OutpatientRechargeRecords;
import com.gxa.modules.pc.fee.dto.OutPatientRechargeDto;
import com.gxa.modules.pc.fee.dto.OutPatientRechargeOrderDto;
import com.gxa.modules.pc.fee.dto.OutPatientRechargePatientDto;
import com.gxa.modules.pc.fee.dto.OutPatientSearchDto;
import com.gxa.modules.pc.fee.mapper.OutpatientRechargeRecordsMapper;
import com.gxa.modules.pc.fee.service.OutpatientRechargeRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 门诊充值记录表 服务实现类
 * </p>
 *
 * @author gxa
 * @since 2022-11-12 05:31:54
 */
@Service
public class OutpatientRechargeRecordsServiceImpl extends ServiceImpl<OutpatientRechargeRecordsMapper, OutpatientRechargeRecords> implements OutpatientRechargeRecordsService {


    @Autowired
    private OutpatientRechargeRecordsMapper orr;

    @Override
    public Result queryAll(OutPatientSearchDto outPatientSearchDto) {
        Integer pageNum1 = outPatientSearchDto.getPageNum();
        Integer pageSize = outPatientSearchDto.getPageSize();
        Integer pageNum2 = (pageNum1-1)*pageSize;
        outPatientSearchDto.setPageNum(pageNum2);
        List<OutPatientRechargeDto> outPatientRechargeDtos = orr.queryAll(outPatientSearchDto);
        Integer count = orr.count(outPatientSearchDto);
        PageUtils pageUtils = new PageUtils(outPatientRechargeDtos, count, pageSize, pageNum1);
        return new Result().ok(pageUtils);
    }

    @Override
    public Map<String, Object> queryByOrderId(String orderId) {
        HashMap<String, Object> map = new HashMap<>();
        List<OutPatientRechargePatientDto> patient = orr.queryByOrderId(orderId);
        List<OutPatientRechargeOrderDto> order = orr.queryOrderByOrderId(orderId);
        map.put("patient", patient);
        map.put("order", order);
        return map;
    }

    @Override
    public void updateRemarks(String orderId, String remarks) {
        orr.updateRemarks(orderId,remarks);
    }
}
